home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_100 / 130_01 / g82.asm < prev    next >
Assembly Source File  |  1985-03-09  |  4KB  |  120 lines

  1.         page    55
  2.         maclib  bds
  3.         maclib  cmac
  4.  
  5.         direct
  6.         define  swaphl
  7.         define  wait
  8.         define  getplot
  9.         enddir
  10. ;
  11. ;********************************************************
  12. ;*                                                      *
  13. ;*              BDS-C Supplementary Library             *
  14. ;*                      release 2                       *
  15. ;*                                                      *
  16. ;*              Steve de Plater, Nov. 1980              *
  17. ;*                    66 Priam St.                      *
  18. ;*                    Chester Hill,                     *
  19. ;*                    NSW, 2162                         *
  20. ;*                    Australia                         *
  21. ;*              Phone: (02) 644 4009                    *
  22. ;*                                                      *
  23. ;*              This file: G82.ASM release 1            *
  24. ;*                                                      *
  25. ;********************************************************
  26. ;
  27. ;============================================================= 
  28. ;
  29. ; int swaphl(p1)
  30. ;  int p1;
  31. ;
  32. ;    Returns the 16 bit word P1 with HI and LO bytes swapped.
  33. ;
  34.         prelude swaphl
  35.  
  36.         call    ma1toh          ;get the word to swap to HL
  37.         mov     d,h             ;and swap it!
  38.         mov     h,l
  39.         mov     l,d
  40.         ret
  41.  
  42.         postlude swaphl
  43. ;
  44. ;
  45. ;============================================================= 
  46. ;
  47. ; int wait(port,mask,polarity);
  48. ;
  49. ;    Used to generate tight status port loops
  50. ;    If polarity is TRUE (non zero) then the routine returns
  51. ;    when (PORT AND MASK) gives a ZERO result
  52. ;    (ie when PORT and MASK have NO bits in common)
  53. ;    If polarity is FALSE (zero) then the routine returns
  54. ;    when (PORT AND MASK) gives a NON ZERO result
  55. ;    (ie when PORT and MASK have SOME bits in common)
  56. ;    The value returned is data input from the port.
  57. ;
  58.         prelude wait
  59.  
  60.         call    arghak          ;get the parameters
  61.         push    b
  62.  
  63.         lda     arg1            ;the port number
  64.         reloc   sta,wait2a      ;I hate self
  65.         reloc   sta,wait4a      ;  modifying
  66.         reloc   sta,wait6a      ;    code!
  67.         lda     arg2            ;the MASK
  68.         mov     b,a
  69.         lda     arg3            ;the polarity
  70.         ora     a               ;false polarity ?
  71.         reloc   jz,wait4        ;yes - jump
  72. wait2:  in      0               ;input the port
  73.         ana     b               ;and MASK
  74.         reloc   jnz,wait2       ;and loop while NZ
  75.         reloc   jmp,wait6
  76. wait4:  in      0               ;input the port
  77.         ana     b               ;and MASK
  78.         reloc   jz,wait4        ;and loop while Z
  79. wait6:  in      0               ;get the port again
  80.         mov     l,a             ;and into HL
  81.         mvi     h,0
  82.         pop     b
  83.         ret
  84.  
  85. wait2a  equ     wait2+1         ;KLUDGE!
  86. wait4a  equ     wait4+1
  87. wait6a  equ     wait6+1
  88.  
  89.         postlude wait
  90. ;
  91. ;==============================================================
  92. ;
  93. ; int *getplot()
  94. ;
  95. ;   Returns a pointer to the beginning of the data area in
  96. ;   c.ccc which contain the dma plotting information.
  97. ;
  98. ;    int *pbase;        /* points to base addr of screen RAM */
  99. ;    int *ysize;        /* points to no. of columns          */
  100. ;    int *xsize;        /* points to no. of rows             */
  101. ;    int *psize;        /* points to size of plot area       */
  102. ;
  103. ;    pbase=getplot();
  104. ;    ysize=pbase+1;     /* pointers are NOT integers         */
  105. ;    xsize=ysize+1;
  106. ;    psize=xsize+1;
  107. ;
  108.         prelude getplot
  109.  
  110.         lxi     h,pbase
  111.         ret
  112.  
  113.         postlude getplot
  114. ;
  115. +1;
  116. ;    psize=xsize+1;
  117. ;
  118.         prelude getplot
  119.  
  120.         lxi